/*
 * Copyright (C) 2012  Romain DUBOIS
 * 
 * This file is part of NeMoS - Network and Modular Software
 * 
 * NeMoS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * NeMoS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with NeMoS.  If not, see <http://www.gnu.org/licenses/>.
 */
package nemos.launch;

import static nemos.launch.EProgressListenerCall.ENDED;
import static nemos.launch.EProgressListenerCall.INITIALIZED;
import static nemos.launch.EProgressListenerCall.UPDATED;

import java.util.ArrayList;
import java.util.List;

import nemos.launch.progress.IProgressListener;
import nemos.launch.progress.IRecords;
import nemos.launch.progress.IStatus;

/**
 * ProgressListenerTestImpl : The progress listener test implementation.
 * 
 * @author Romain DUBOIS
 */
public class ProgressListenerTestImpl implements IProgressListener {

    /** The calls */
    private final List<EProgressListenerCall> mCalls;
    /** The statuses */
    private final List<IStatus> mStatuses;
    /** The record of previous launches */
    private IRecords mRecords;
    /** The target start level */
    private int mTargetLevel;

    /**
     * Constructor
     */
    public ProgressListenerTestImpl() {
        super();

        mCalls = new ArrayList<EProgressListenerCall>();
        mStatuses = new ArrayList<IStatus>();
    }

    /**
     * {@inheritDoc}
     * 
     * @see nemos.launch.progress.IProgressListener#init(nemos.launch.progress.IRecords,
     *      int)
     */
    @Override
    public void init(final IRecords pRecords, final int pTargetLevel) {
        mRecords = pRecords;
        mTargetLevel = pTargetLevel;
        mCalls.add(INITIALIZED);
    }

    /**
     * {@inheritDoc}
     * 
     * @see nemos.launch.progress.IProgressListener#progressChanged(nemos.launch.progress.IStatus)
     */
    @Override
    public void progressChanged(final IStatus pStatus) {
        mCalls.add(UPDATED);
        mStatuses.add(new TestStatus(pStatus));
    }

    /**
     * {@inheritDoc}
     * 
     * @see nemos.launch.progress.IProgressListener#ended()
     */
    @Override
    public void ended() {
        mCalls.add(ENDED);
    }

    /**
     * Get the provided records.
     * 
     * @return The records
     */
    public IRecords getRecords() {
        return mRecords;
    }

    /**
     * Get the target start level.
     * 
     * @return The target start level
     */
    public int getTargetLevel() {
        return mTargetLevel;
    }

    /**
     * Get the call list.
     * 
     * @return The calls
     */
    public List<EProgressListenerCall> getCalls() {
        return mCalls;
    }

    /**
     * Get the received statuses.
     * 
     * @return The statuses
     */
    public List<IStatus> getStatuses() {
        return mStatuses;
    }
}
